package com.youkeda.yikao.web.control;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.SessionAttribute;

import javax.servlet.http.HttpSession;
import java.util.Date;

@RestController
public class SessionControl {
    @RequestMapping(path = "/session/add")
    public String addsession(HttpSession session){

        session.setAttribute("msg","Hello ");
        session.setAttribute("text",new Date());
        session.setAttribute("text2",new Date());

        return "add session";
    }
    @RequestMapping(path = "/session/get")
    public String getsession(@SessionAttribute(value = "msg",required = false) String msg,
                             @SessionAttribute(value = "text",required = false) Date text){
        return "get session"+msg+"||"+text;
    }
}
